<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-31 17:46:49
 * @LastEditTime: 2019-11-28 15:58:02
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../../css/local.css" />
    <link rel="stylesheet" type="text/css" href="../../font/iconfont.css" />
    <link rel="stylesheet" href="../../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/layer/layer.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script src="../../script/elementui/lib/index.js?t=1"></script>
    <script src="../../script/elementui/vue-element-bigdata-table.min.js?t=4"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <script type="text/javascript" src="../../script/JSLINQ.js"></script>
    <script type="text/javascript" src="../../script/ajaxFileUpload.js"></script>
    <style type="text/css">
        body {
            zoom: 0.9;
        }

        .innerBox {
            flex: 1;
            overflow: auto;
        }

        .mainForm {
            width: 99%;
            overflow-y: auto;
            display: flex;
            flex-wrap: wrap;
        }

        .mainForm .van-field {
            width: 50%;
        }

        .van-field__label {
            width: auto;
        }

        .subFrame {
            padding-bottom: 50px;
        }

        .title {
            width: 40%;
            background-color: #83bff6;
            text-align: center;
            margin: 2px auto 2px 0;
            padding: 2px 1px;
            color: #fff;
            font-size: 16px;
        }

        .table {
            width: 100%;
            overflow: auto;
            height: auto;
            border-bottom: 0;
            border-right: 0;
        }

        table {
            white-space: nowrap;
            border-collapse: separate;
            table-layout: fixed;
            top: 0;
        }

        .table table th {
            text-align: center;
            padding: auto 5px;
            background-color: lightblue;
            position: sticky;
            top: 0;
            z-index: 1;
        }

        .van-icon-delete {
            color: red;
        }

        td {
            text-align: center;
        }

        .equipmentBox {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
        }

        .equipmentBox .van-tag {
            width: 75%;
            margin-top: 4px;
            margin-right: 8px;
        }

        .tagTitlt {
            width: 90%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: inline-block;
        }

        .equipmentBox .van-button {
            width: 10%;
            margin-top: 4px;
        }

        input {
            background: none;
            outline: none;
            border: none;
        }

        .van-dialog__confirm,
        .van-dialog__confirm:active {
            color: #1989fa;
        }

        .part1 {
            padding: 15px 15px 0 15px;
        }

        .part1 .pf {
            border-radius: 6px;
            box-shadow: 0px 1px 5px rgb(200, 198, 198);
            background-color: #fff;
            overflow: hidden;
        }

        .textarea {
            display: block;
        }

        .label {
            padding: 10px 16px;
        }

        .ap-f {
            border-bottom: 1px solid #f7f7f7;
        }

        .mark {
            padding: 17px 15px;
        }

        .mark1 {
            padding: 17px 5px 17px 15px;
            position: relative;
        }

        .f-sub {
            color: #969799;
            font-size: 13px;
            margin-top: 4px;
        }

        .line {
            position: relative;
            width: 30px;
        }

        .line1 {
            width: 60px;
        }

        .line-sq {
            display: inline-block;
            width: 11px;
            height: 11px;
            border-radius: 6px;
            background: #d6d6d6;
            position: absolute;
            left: 0;
            top: 12px;
        }

        .line-li {
            display: inline-block;
            width: 1px;
            background: #d6d6d6;
            position: absolute;
            left: 5px;
            top: -17px;
            bottom: -17px;
        }

        .line-li1 {
            display: inline-block;
            background: #d6d6d6;
            position: absolute;
            top: 52px;
            left: 35px;
            width: 3px;
            bottom: 10px;
        }

        .pd {
            padding: 16px 0;
        }

        .ap-r {
            text-align: right;
            padding-right: 10px;
            /* margin: -8px 0; */
            padding-top: 10px;
        }

        .ap-d {
            text-align: right;
            padding-right: 10px;
            color: #ccccce;
            font-size: 13px;
            float: right;
            padding-top: 3px;
        }

        .img {
            width: 34px;
            height: 34px;
            line-height: 34px;
            text-align: center;
            font-size: 12px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            margin: 0 auto;
            position: relative;
            user-select: none;
        }

        .img1 {
            width: 44px;
            height: 44px;
            line-height: 44px;
            text-align: center;
            font-size: 13px;
            color: #fff;
            background-color: #3396fb;
            border-radius: 6px;
            position: relative;
            user-select: none;
        }

        .dis-ib {
            display: inline-block;
            vertical-align: middle;
            text-align: center;
            min-width: 40px;
        }

        .dis2-ib {
            display: inline-block;
            vertical-align: middle;
            padding-bottom: 3px;
            text-align: center;
        }

        .dis3-ib {
            display: inline-block;
            margin: 0 6px;
            color: #969799;
            vertical-align: top;
            padding-top: 7px;
            text-align: center;
        }

        .ap-n {
            padding-top: 2px;
            font-size: 13px;
            color: #969799;
            text-align: center;
        }

        .bottom {
            padding: 8px 15px;
        }

        .part-white {
            padding: 15px;
            background-color: #fff;
            position: relative;
        }

        .title {
            line-height: 40px;
            font-size: 18px;
        }

        .title-sub {
            color: #aaacac;
            font-size: 13px;
        }

        .title-read {
            color: #3396fb;
            font-size: 13px;

        }

        .title-unread {
            color: #788a8a;
            font-size: 13px;
        }

        .ap-res {
            color: #a3a3a3;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-res1 {
            color: #c31616;
            font-size: 15px;
            padding-top: 6px;
        }

        .ap-img {
            position: absolute;
            right: 20px;
            bottom: -38px;
            width: 88px;
            opacity: 0.4;
        }

        .form-row {
            padding: 4px 16px;
        }

        .form-label {
            color: #808991;
            font-size: 13px;
            user-select: none;
        }

        .form-content {
            padding-top: 5px;
        }

        .npd {
            padding-top: 0;
            overflow-x: auto;
        }

        .pl {
            color: #969799;
            font-size: 16px;
            margin: 6px 2px 18px 0;
            min-height: 25px;
            border-bottom: 1px solid #ebedf0;
        }

        .sf {
            width: 16px;
            background: #fff;
            padding: 2px;
            border-radius: 8px;
            position: absolute;
            right: -5px;
            bottom: -2px;
        }

        .select {
            color: #3396fb;
            float: right;
            font-size: 13px;
            padding-top: 3px;
            vertical-align: middle;
        }

        .select a {
            vertical-align: middle;
        }

        .select img {
            width: 16px;
            vertical-align: middle;
        }

        .hq {
            padding: 10px 10px 0 0;
        }

        .wh {

            white-space: nowrap;
            overflow-x: auto;
            padding-right: 10px;
        }

        .plpd {
            padding-bottom: 5px;
        }

        .pictitle {
            line-height: 24px;
            color: #646566;
            user-select: none;
        }

        .piccontent {
            padding-top: 10px;
            overflow: hidden;
        }

        .van-uploader__preview {
            margin-right: 15px;
        }

        .no {
            text-align: center;
            color: #808991;
            font-size: 14px;
        }

        .li1 {
            top: 15px;
        }

        .li2 {
            bottom: 24px;
        }

        .da-c {
            color: #c31616;
        }

        .danger .van-field__control {
            color: #c31616;
        }

        .danger .van-field__label {
            color: #808991;
        }

        .ac-1 {
            color: #03b553;
        }

        .ac-2 {
            color: #c31616;
        }

        .checkbox {
            padding: 25px 5px 10px 10px;
        }

        .jl-remark {
            padding: 5px 0;
            color: #3396fb;
        }

        .memo-l {
            border-bottom: 1px solid rgb(235, 237, 240);
            padding: 4px 0;
        }

        .memo-l:last-child {
            border-bottom: 0;
        }

        .approvePop {
            box-sizing: border-box;
            padding: 20px 30px;
        }

        .approvePop .approveBtns {
            position: absolute;
            bottom: 0;
            width: 100%;
            box-sizing: border-box;
            display: flex;
        }

        .approvePop .approveBtns .van-button {
            width: 60%;
            margin: auto;
        }

        .van-button--small {
            float: right;
            top: -10px;
        }

        .van-icon-play-circle-o {
            color: #f5f5f5;
            font-size: 50px;
            vertical-align: middle;
            position: absolute;
            z-index: 1;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" id="box">
            <van-nav-bar id="van-nav-bar" :title="titleName" left-arrow @click-left="onClickLeft">
            </van-nav-bar>

            <div class="innerBox">
                <div class="mainForm">
                    <van-field v-model="formData.BillNO" label="单据编号" placeholder="自动生成" readonly>
                    </van-field>
                    <van-field v-model="formData.ReviewStatus" label="审批状态" placeholder="请输入审批状态" readonly>
                    </van-field>
                    <van-field v-model="formData.BillDate" label="发生日期" placeholder="请输入发生日期" readonly
                        @click="showDate = true">
                    </van-field>
                    <van-field v-model="formData.SupplierName" label="责任单位" placeholder="请输入责任单位" :readonly="nameshow">
                    </van-field>
                    <van-field v-model="formData.OrderNumber" label="订单号&工单号" placeholder="请输入订单号&工单号"
                        :readonly="nameshow">
                    </van-field>
                    <van-field v-model="formData.FRemarks" label="扣款原因" placeholder="请输入扣款原因" :readonly="FRemarksEdit">
                    </van-field>
                    <van-field v-model="formData.TotalMoney" label="总金额" placeholder="请输入总金额" readonly>
                    </van-field>
                    <van-field name="uploader" label="图片" readonly style='width: 100%;'>
                        <template #input>
                            <div class="van-uploader">
                                <!-- 整行图片 -->
                                <div class="van-uploader__wrapper">
                                    <!-- 单个照片 -->
                                    <div class="van-uploader__preview" v-for="(item, index) in imgList">
                                        <van-image @click="previewImg" width="80" height="80"
                                            :src="serverIP + item.url">
                                        </van-image>
                                        <div @click="deleteImg(index)" class="van-uploader__preview-delete"
                                            style="width: 30px; height: 30px">
                                            <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                                                style="font-size: 30px"></i>
                                        </div>
                                    </div>

                                    <!-- 上传图片的按钮 -->
                                    <div v-show="imgList.length < 9" class="van-uploader__upload"
                                        @change="uploadNewFile(1)">
                                        <i
                                            class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                        <input type="file" name="newFile1" id="newFile1" accept="image/*"
                                            class="van-uploader__input">
                                    </div>
                                </div>
                            </div>
                        </template>
                    </van-field>

                    <van-field name="uploader" label="视频" readonly style='width: 100%;'>
                        <template #input>
                            <div class="van-uploader">
                                <!-- 整行图片 -->
                                <div class="van-uploader__wrapper">
                                    <!-- 单个照片 -->
                                    <div class="van-uploader__preview" v-for="(item, index) in videoImgList">
                                        <!-- <van-icon name="play-circle-o" @click="previewVideo(index)"></van-icon>
                                         <van-image width="80" height="80" :src="serverIP + item.url">
                                         </van-image> -->
                                        <van-image width="80" height="80" :src="item.url" @click="previewVideo(index)">
                                        </van-image>

                                        <div @click="deleteVideo(index)" class="van-uploader__preview-delete"
                                            style="width: 30px; height: 30px">
                                            <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                                                style="font-size: 30px"></i>
                                        </div>
                                    </div>

                                    <!-- 上传图片的按钮 -->
                                    <div v-show="videoImgList.length < 9" class="van-uploader__upload"
                                        @change="uploadNewFile(2)">
                                        <i
                                            class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                        <input type="file" name="newFile2" id="newFile2" accept="video/*"
                                            class="van-uploader__input">
                                    </div>
                                </div>
                            </div>
                        </template>
                    </van-field>
                </div>

                <div class="subFrame">
                    <div class="title">供应商质量明细</div>
                    <van-button v-show="!api.pageParam.historyData" icon="plus" size="small" type="info"
                        @click="addNew">新增</van-button>
                    <div class="table" id="table">
                        <table style="width: 1300px;">
                            <tr>
                                <th width="3%">序号</th>
                                <th width="5%">品名</th>
                                <th width="8%">图号或代号</th>
                                <th width="8%">产品数量</th>
                                <th width="5%">不良数或不良比例</th>
                                <th width="5%">说明文字</th>
                                <th width="3%">返工返修费&运输费</th>
                                <th width="3%">配件&辅助材料损失费</th>
                                <th width="5%">处罚费</th>
                                <th width="5%">客诉费</th>
                                <th width="12%">其它</th>
                                <th width="12%">扣款总金额(元)</th>
                            </tr>

                            <tr v-for="(item, index) in tableData">
                                <td>
                                    {{index + 1}}
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.ProductName"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @click="openBaseScreen('品名', index)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.CPTH"
                                        :readonly="approvalList.length ? 'readonly' : false"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.TotalQuantity"
                                        :readonly="approvalList.length ? 'readonly' : false"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.DisqualificationRatio"
                                        :readonly="approvalList.length ? 'readonly' : false"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.FRemarks"
                                        :readonly="approvalList.length ? 'readonly' : false"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.TransportationCharge"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @input="handlerMoney(item)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.LossCharge"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @input="handlerMoney(item)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.PenaltyFee"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @input="handlerMoney(item)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="number" v-model="item.CustomerFee"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @input="handlerMoney(item)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.OtherFee"
                                        :readonly="approvalList.length ? 'readonly' : false"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.TotalMoney"
                                        :readonly="approvalList.length ? 'readonly' : false"
                                        @input='addInput(item)'></input>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>

                <div class="subFrame1" v-if="approvalList.length">
                    <div class="part1" v-for="approvalRow in approvalList">
                        <div class="pf">
                            <div class="label">流程</div>
                            <div class="pd">
                                <div>
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1"><span>{{formData.UserName}}</span><img
                                                                class="sf" src="../../image/success.png" /></div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div>
                                                    <span>发起审批</span>
                                                    <span
                                                        class="ap-d">{{formData.BillDate.split('.')[0].replace(/T/g,'')}}</span>
                                                </div>
                                                <div class="f-sub">{{formData.UserName}}</div>
                                            </div>
                                            <div class="pl"></div>
                                        </div>
                                    </div>
                                </div>
                                <div v-for="(row,index) in approvalRow.approvalNodeList">
                                    <div class="flex-box f-r">
                                        <div class="mark1 npd" v-if="!row.node[0].showAll">

                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">

                                                        <div class="img1" @click="row.node[0].showAll=true">
                                                            <span style="position: absolute;top: -35%;right: 0;"
                                                                v-show='row.node[0].CurrentApprovalIDs.length>1'>
                                                                <van-icon name="more"></van-icon>
                                                            </span>
                                                            <span
                                                                v-if="row.node.length == 1 && row.type == 0">{{row.node[0].CurrentApprovalIDs[0]}}</span>
                                                            <van-icon v-else-if="row.type == 1" name="volume-o"
                                                                size="28px" style="padding-top: 7px;">
                                                            </van-icon>
                                                            <van-icon v-else name="friends-o" size="28px"
                                                                style="padding-top: 7px;"></van-icon>
                                                            <img class="sf"
                                                                v-if="approvalRow.level == row.index - 2 && row.type == 1 && row.node[0].Approve != 0"
                                                                src="../../image/success.png" />
                                                            <img class="sf" v-if="approvalRow.level >= row.index - 1"
                                                                :src="getApprovalTagImg(row)" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"></div>
                                            </div>

                                        </div>
                                        <div class="mark1 npd " v-else v-for='ite,idx in row.node[0].CurrentApprovalIDs'
                                            :key='idx'>
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span style="position: absolute;top: -35%;right: 0;"
                                                                @click="row.node[0].showAll=false"
                                                                v-show='row.node[0].CurrentApprovalIDs.length>1'>
                                                                <van-icon name="more" v-show='idx==0'></van-icon>
                                                            </span>
                                                            <div v-if="row.node.length == 1 &&  row.type == 0">
                                                                {{ite}}
                                                            </div>
                                                            <van-icon v-else-if="row.type == 1" name="volume-o"
                                                                size="28px" style="padding-top: 7px;">
                                                            </van-icon>
                                                            <van-icon v-else name="friends-o" size="28px"
                                                                style="padding-top: 7px;"></van-icon>
                                                            <img class="sf"
                                                                v-if="approvalRow.level == row.index - 2 && row.type == 1 && row.node[0].Approve != 0"
                                                                src="../../image/success.png" />
                                                            <img class="sf" v-if="approvalRow.level >= row.index - 1"
                                                                :src="getApprovalTagImg(row)" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>

                                        </div>
                                        <div class="flex-main npd">
                                            <div>
                                                <div class="hq" v-if="row.showMore">
                                                    <!-- 或签 -->
                                                    <div class="wh"
                                                        v-if="row.node.length == 1 && row.node[0].CurrentApprovalIDs.length > 1">
                                                        <div class="dis2-ib"
                                                            v-for="(item,itemIndex) in row.node[0].CurrentApprovalIDs">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item)}}</span>
                                                                    <img class="sf"
                                                                        v-if="item == row.node[0].Approver && approvalRow.level >= row.index - 1 && row.node[0].Approve != 0"
                                                                        :src="row.node[0].Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node[0].CurrentApprovalIDs.length - 1 && row.type == 0">
                                                                /</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>

                                                    </div>
                                                    <!-- 会签 -->
                                                    <div class="wh" v-if="row.node.length > 1 && checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis-ib">
                                                                <div class="img">
                                                                    <span>{{cutStr(item.CurrentApprovalIDs[0])}}</span>
                                                                    <img class="sf"
                                                                        v-if="item.Approver && item.Approver == item.CurrentApprovalIDs[0] && approvalRow.level >= row.index - 1 && item.Approve != 0"
                                                                        :src="item.Approve == 1?'../../image/success.png':'../../image/fail.png'" />
                                                                </div>
                                                                <div class="ap-n">{{item.CurrentApprovalIDs[0]}}</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1 && row.type == 0">
                                                                +</div>
                                                            <div class="dis3-ib" v-if="row.type == 1"> </div>
                                                        </div>
                                                    </div>
                                                    <!-- 多人审核 -->
                                                    <div class="wh" v-if="row.node.length > 1 && !checkIsSingle(row)">
                                                        <div class="dis2-ib" v-for="(item,itemIndex) in row.node">
                                                            <div class="dis2-ib"
                                                                v-for="(detail,detailIndex) in item.CurrentApprovalIDs">
                                                                <div class="dis-ib">
                                                                    <div class="img">
                                                                        <span>{{cutStr(detail)}}</span>
                                                                    </div>
                                                                    <div class="ap-n">{{detail}}
                                                                    </div>
                                                                </div>
                                                                <div class="dis3-ib"
                                                                    v-if="itemIndex != row.node.length - 1">/</div>
                                                            </div>
                                                            <div class="dis3-ib"
                                                                v-if="itemIndex != row.node.length - 1">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="pl">
                                                    <div class="plpd" v-for="item in row.node">
                                                        <div>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">{{item.Approver}}:</span>
                                                            <span v-if="item.ApprovalContent"
                                                                :class="'ac-' + item.Approve">"{{item.ApprovalContent}}"</span>
                                                            <div class="ap-d" v-if='item.ApprovalContent'>
                                                                  {{item.ApproveTime}}
                                                            </div>
                                                        </div>

                                                        <div class="piccontent" v-if="item.Imgs">
                                                            <div class="van-uploader">
                                                                <div class="van-uploader__wrapper">
                                                                    <div class="van-uploader__preview"
                                                                        v-for="(imgItem,imgItemIndex) in (item.Imgs?item.Imgs.split(','):[])">
                                                                        <div class="van-image van-uploader__preview-image"
                                                                            style="overflow: hidden; border-radius: 4px;width:60px;height:60px;"
                                                                            @click="previewItemImage(item.Imgs,imgItemIndex,3)">

                                                                            <img :src="serverIP + imgItem"
                                                                                class="van-image__img"
                                                                                style="object-fit: cover;" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="flex-box f-r" v-if="index == approvalRow.approvalNodeList.length - 1">
                                        <div class="mark1 npd">
                                            <div class="line1">
                                                <div>
                                                    <div class="dis-ib">
                                                        <div class="img1">
                                                            <span>备注</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="line-li1"
                                                    v-if="index != approvalRow.approvalNodeList.length - 1"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bottomSubmit"
                    style="position: fixed;bottom: 0px;z-index: 1;width: 100%;padding: 5px 10px;right:0px">
                    <div style="float:right;width:20%;" v-if="whetherShowBtn">
                        <van-button v-if="!btnShow" round block type="info" native-type="submit" @click="saveRow"
                            :disabled="approveDisabled">提交
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="approveFalg">
                        <van-button round block type="info" native-type="submit" @click="submit(0)">重新发起审批</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(3)">退回</van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(2)">拒绝</van-button>
                    </div>

                    <div style="float:right;width:30%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="submit(1)">输入审核意见/确认同意
                        </van-button>
                    </div>
                    <div style="float:right;width:20%;" v-if="!whetherShowBtn && btnShow">
                        <van-button round block type="info" native-type="submit" @click="dialogVisible = true">转交
                        </van-button>
                    </div>
                </div>
                <el-dialog title="转交" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
                    <!-- <span>这是一段信息</span> -->
                    <el-select v-model="TransmittedUserID" filterable placeholder="请选择">
                        <el-option v-for="item in options" :key="item.userid_num" :label="item.user_name"
                            :value="item.userid_num">
                        </el-option>
                        </el-option>
                    </el-select>

                    <span slot="footer" class="dialog-footer">
                        <el-button @click="dialogVisible = false">取 消</el-button>
                        <el-button type="primary" @click="Transmitted">确 定</el-button>
                    </span>
                </el-dialog>
                <van-popup class="approvePop" v-model="approveShow" closeable close-icon="close" position="bottom"
                    :style="{ height: '40%' }">
                    <van-field v-model="approveData.approveData" label="审批意见" placeholder="请输入审批意见"></van-field>
                    <div class="approveBtns">
                        <van-button type="info" @click="approveSave">保存</van-button>
                    </div>
                </van-popup>

                <van-popup position="bottom" v-model="showDate">
                    <van-datetime-picker v-model="currentDate" type="date" title="选择生产日期" @confirm="confirmDate"
                        @cancel="showDate = false"></van-datetime-picker>
                </van-popup>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        var FNPhotograph = api.require('FNPhotograph');
        var photoBrowser = api.require('photoBrowser');
        var mediaCollector = api.require('mediaCollector');

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            if (ret.value.type == '品名') {
                vm.tableData[vm.currentRowIndex].ProductName = ret.value.row.ProductName
                vm.tableData[vm.currentRowIndex].CPTH = ret.value.row.TH
            }
        })

        vm = new Vue({
            el: '#app',
            data: {
                options: [],
                TransmittedUserID: '',
                dialogVisible: false,
                nameshow: false,
                titleName: api.pageParam.titleName,
                isPDA: api.deviceModel.indexOf('PDA') > -1 ? true : false,
                serverIP: APP.serverIP(),
                approvalID: '',
                formData: {
                    DeductMoneyID: '',
                    FType: '',
                    ReviewStatus: '',
                    BillDate: '',
                    BillNO: '',
                    SupplierName: '',
                    OrderNumber: '',
                    FRemarks: '',
                    APFlowID: '',
                    FilePath: '',
                    FilePath1: '',
                    FilePath2: '',
                    TotalMoney: 0
                },
                tableData: [
                    {
                        DeductMoneyDeID: '',
                        DeductMoneyID: '',
                        ProductName: '',
                        CPTH: '',
                        TotalQuantity: '',
                        DisqualificationRatio: '',
                        FRemarks: '',
                        TransportationCharge: '',
                        LossCharge: '',
                        PenaltyFee: '',
                        CustomerFee: '',
                        OtherFee: '',
                        TotalMoney: '',
                    }
                ],
                approveFalg: false,
                btnShow: false,
                whetherShowBtn: true,
                finalResult: false,
                approvalList: [],
                status: 0,
                approveData: {
                    content: ''
                },
                approveFlag: false,
                approveShow: false,
                finalDisable: true,
                finalBtn: false,
                currentRowIndex: 0,
                imgList: [],
                videoList: [],
                videoImgList: [],
                showDate: false,
                currentDate: new Date(),
                FRemarksEdit: 'readonly',
                approveDisabled: false,
                showAll: false,
                showAllIndex: ''
            },
            created: function () {
                var that = this
                that.FRemarksEdit = false
                that.formData.ReviewStatus = '未审批'
                console.log('pageParam', JSON.stringify(api.pageParam.historyData))
                that.zhuanjiao()

                if (api.pageParam.historyData) {
                    console.log('historyData', window.localStorage.getItem('name'))
                    console.log('historyData', JSON.stringify(APP.getUserInfo().UserName))
                    if (window.localStorage.getItem('name') == APP.getUserInfo().UserName) {
                        that.nameshow = false
                    } else {
                        that.nameshow = true
                    }
                    console.log('nameshow', JSON.stringify(that.nameshow))

                    that.formData.DeductMoneyID = api.pageParam.historyData.DeductMoneyID ? api.pageParam.historyData.DeductMoneyID : api.pageParam.historyData.BadReviewID
                    that.getInitHistoryData()
                    var obj = {
                        BadReviewID: that.formData.DeductMoneyID,
                        ReviewType: 5
                    }
                    APP.ajax('selectBHGPSIDByDGID', obj, function (res) {
                        console.log('selectBHGPSIDByDGID', JSON.stringify(res))
                        if (res.ds.length) {  //获取评审流程
                            that.whetherShowBtn = false
                            that.FRemarksEdit = 'readonly'
                            that.formData.Ck_DeductPSReviewID = res.ds[0].Ck_DeductPSReviewID
                            that.approvalID = res.ds[0].APFlowID
                            that.getHistoryData()
                            that.checkIsShowButton()
                        }
                    })
                }
            },
            mounted() {
                var navBar = document.getElementById('van-nav-bar')
                navBar.style.paddingTop = api.safeArea.top + 'px'
            },
            methods: {
                handleClose() {
                    var that = this
                    that.dialogVisible = false
                },
                Transmitted() {
                    var that = this
                    var obj = {
                        TableName: 'Pr_DeductMoney',
                        APFlowID: 7,
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        ReviewType: 5,
                        ApprovalID: that.formData.DeductMoneyID,
                        UserCode: that.TransmittedUserID
                    }

                    console.log('BhgQjzjpsbgApproveList', JSON.stringify(obj))
                    APP.ajax('BhgQjzjpsbgApprove', obj, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            that.dialogVisible = false
                            api.toast({
                                msg: res.ds[0].msg
                            })
                            that.addSP_Message(4)
                        }

                    })
                    // that.dialogVisible = false
                },
                zhuanjiao(val) {
                    var that = this
                    APP.ajax('PC_PCRYXL', {}, function (res) {
                        // console.log('PC_PCRYXL',JSON.stringify(res))
                        that.options = res.ds
                    })
                },
                addSP_Message(val) {
                    var that = this
                    var obj1 = {
                        SourceTable: 'Pr_DeductMoney',
                        ApprovalSortCZ: that.approvalList[that.approvalList.length - 1].level + 1,
                        SourceID: that.formData.DeductMoneyID,
                        UserCode: that.TransmittedUserID,
                        Status: val,
                        UserID: APP.getUserInfo().UserID,
                    }
                    console.log('level', JSON.stringify(obj1))
                    APP.ajax('SP_Message', obj1, function (res) {
                        if (res.ds[0].status == 200) {
                            console.log('BhgQjzjpsbgApprove', JSON.stringify(res))
                            api.toast({
                                msg: res.ds[0].msg
                            })
                        }
                    })

                },

                changeshowAll(index) {
                    var that = this
                    that.showAllIndex = index
                    that.showAll = !that.showAll
                },
                confirmDate(val) {
                    var that = this
                    that.formData.BillDate = APP.getFormatDate(val).split(' ')[0]
                    that.showDate = false
                },
                previewImg() {
                    var that = this
                    document.activeElement.blur();
                    var imgFlag = 0
                    var imageArr = []
                    that.imgList.map((item) => {
                        imageArr.push(that.serverIP + item.url)
                    })
                    photoBrowser.open({
                        images: imageArr,
                        bgColor: '#000'
                    }, function (ret, err) {
                        if (ret) {
                            // alert(JSON.stringify(ret));
                            if (ret.eventType == 'show') {
                                imgFlag = 1
                            }
                            if (ret.eventType == 'click') {
                                imgFlag = 0
                                photoBrowser.close();
                            }
                        } else {
                            layer.open({
                                content: '图片打开失败，请重试！',
                                skin: 'msg',
                                time: 2
                            });
                        }
                    });
                },

                deleteImg(index) {
                    var that = this
                    that.imgList.splice(index, 1)
                },
                uploadNewFile(index) {
                    var that = this
                    if (index == 1) {
                        var url = APP.serverIP() + '/Frame/uploadImgFile?dirName=首件检';
                    } else {
                        var url = APP.serverIP() + '/Frame/uploadFile?dirName=首件检';
                    }
                    $.ajaxFileUpload({
                        type: 'POST',
                        url: url,
                        secureuri: false,
                        fileElementId: 'newFile' + index,
                        dataType: 'json',
                        success: function (datas, status) {
                            if (datas.status == 200) {
                                console.log('1178datas', JSON.stringify(datas))
                                if (index == 1) {
                                    that.imgList.push({ url: datas.data.origin })
                                }
                                else if (index == 2) {
                                    that.videoList.push({ url: datas.data })
                                    var img = '../../image/Flash.png'
                                    that.videoImgList.push({ url: img })
                                }
                            } else {
                                vm.$toast('上传失败');
                            }
                        },
                        error: function (data, status, e) {
                            console.log('失败data', JSON.stringify(data))
                        }

                    });

                },

                addImg() {
                    var that = this
                    document.activeElement.blur();
                    FNPhotograph.open({
                        path: 'fs://savePath',
                        album: true,
                        quality: 'medium'
                    }, function (ret) {
                        // alert(JSON.stringify(ret));
                        if (ret.eventType == 'takePhoto') {
                            that.$toast('照片上传中...')
                            APP.uploadFile('首件检', ret.imagePath, function (path) {
                                console.log('path', JSON.stringify(path))
                                that.imgList.push({ url: path })
                            })
                            FNPhotograph.close(
                                function (ret) {
                                    if (ret) {
                                        // alert(JSON.stringify(ret));
                                    }
                                });
                        } else if (ret.eventType == 'cameraError') {
                            that.$toast('相机打开失败，请重试！')
                        }
                    });
                },
                previewVideo(videoIndex) {
                    var that = this
                    console.log('videoPath', JSON.stringify(that.serverIP + that.videoList[videoIndex].url))
                    mediaCollector.videoPreview({
                        videoPath: that.serverIP + that.videoList[videoIndex].url
                    });
                },

                deleteVideo(index) {
                    var that = this
                    that.videoList.splice(index, 1)
                    that.videoImgList.splice(index, 1)
                },

                addVideo() {
                    var that = this
                    document.activeElement.blur();
                    mediaCollector.openCamera({
                        shootMode: 2,
                    }, function (ret, err) {
                        // alert('ret' + JSON.stringify(ret))
                        if (ret.type === 'video') {
                            that.$toast('视频上传中...')
                            APP.uploadFile('首件检', ret.path, function (videoPath) {
                                // console.log('videoPath', JSON.stringify(videoPath))
                                that.videoList.push({ url: videoPath })
                                // console.log('videoList', JSON.stringify(that.videoList))
                            })
                            APP.uploadFile('首件检', ret.videoThumbnailPath, function (imgPath) {
                                // console.log('imgPath', JSON.stringify(imgPath))
                                that.videoImgList.push({ url: imgPath })
                                // console.log('videoImgList', JSON.stringify(that.videoImgList))
                            })
                        }
                    });
                },
                addNew() {
                    var that = this
                    var newTableData = {
                        DeductMoneyDeID: '',
                        DeductMoneyID: '',
                        ProductName: '',
                        CPTH: '',
                        TotalQuantity: '',
                        DisqualificationRatio: '',
                        FRemarks: '',
                        TransportationCharge: '',
                        LossCharge: '',
                        PenaltyFee: '',
                        CustomerFee: '',
                        OtherFee: '',
                        TotalMoney: '',
                    }
                    that.tableData.push(newTableData)
                },
                handlerMoney(row) {
                    var that = this
                    if (Number(row.LossCharge) || Number(row.PenaltyFee) || Number(row.CustomerFee) || Number(row.TransportationCharge)) {
                        row.TotalMoney = (Number(row.LossCharge) * 10 + Number(row.PenaltyFee) * 10 + Number(row.CustomerFee) * 10 + Number(row.TransportationCharge) * 10) / 10
                        that.addInput()
                    } else {
                        row.TotalMoney = ''
                        that.formData.TotalMoney = ''
                    }
                },
                addInput(row) {
                    that = this
                    var a = 0
                    that.tableData.forEach(item => {
                        if (Number(item.TotalMoney)) {
                            a = Number(a) + Number(item.TotalMoney)
                        }
                    })
                    that.formData.TotalMoney = a
                },
                getInitHistoryData() {
                    var that = this
                    var obj = {
                        DeductMoneyID: that.formData.DeductMoneyID
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('APP_GYSZLKKMX', obj, function (res) {
                        console.log('APP_GYSZLKKMX', JSON.stringify(res))
                        that.formData = res.ds[0]
                        if (that.formData.FilePath && that.formData.FilePath != 'null') {
                            var arr = that.formData.FilePath.split(',')
                            arr.map((item) => {
                                that.imgList.push({ url: item })
                            })
                        } else {
                            that.imgList = []
                        }

                        if (that.formData.FilePath1 && that.formData.FilePath1 != 'null') {
                            var arr = that.formData.FilePath1.split(',')
                            arr.map((item) => {
                                that.videoList.push({ url: item })
                            })
                        } else {
                            that.videoList = []
                        }

                        if (that.formData.FilePath2 && that.formData.FilePath2 != 'null') {
                            var arr = that.formData.FilePath2.split(',')
                            arr.map((item) => {
                                that.videoImgList.push({ url: item })
                            })
                        } else {
                            that.videoImgList = []
                        }

                        that.tableData = res.ds1
                    })
                },

                filterPersonList: function (str, value) {
                    var that = this;
                    var row = null;
                    for (var i in that.personList) {
                        if (that.personList[i][str] == value) {
                            row = that.personList[i];
                            break;
                        }
                    }
                    return row;
                },

                getApprovalTagImg: function (row) {
                    var that = this;
                    if (row.node.length == 1) {
                        if (row.node[0].Approve == 0) {
                            return '../../image/doing.png';
                        } else if (row.node[0].Approve == 1) {
                            return '../../image/success.png';
                        } else if (row.node[0].Approve == 2) {
                            return '../../image/fail.png';
                        }
                    } else {

                        var imgstr = '';
                        var z = 0;
                        for (var i in row.node) {
                            if (row.node[i].Approve == 1) {
                                z++;
                            }
                            if (row.node[i].Approve == 2) {
                                imgstr = '../../image/fail.png';
                                break;
                            }
                        }
                        if (imgstr) {
                            return imgstr;
                        } else {
                            if (z == 0) {
                                imgstr = '../../image/doing.png'
                            } else {
                                if (row.node.length == z) {
                                    imgstr = '../../image/success.png'
                                } else {
                                    imgstr = '../../image/doing.png';
                                }
                            }

                        }
                        return imgstr;
                    }
                },

                getHistoryData() {
                    var that = this
                    var obj = {
                        Ck_ReviewID: that.formData.Ck_DeductPSReviewID,
                        ReviewType: 5
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('getBHGPSCkReviewByID', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        that.status = res.ds[0].Status
                        var obj2 = {
                            P_PKValue: that.formData.DeductMoneyID,
                            P_TableName: 'Pr_DeductMoney'
                        }
                        console.log('obj2', JSON.stringify(obj2))
                        APP.ajax('Select_FlowLog1', obj2, function (res) {
                            console.log('res', JSON.stringify(res))
                            console.log('APP.getUserInfo().UserName', JSON.stringify(APP.getUserInfo().UserName))
                            console.log('res.ds[0].Creater', JSON.stringify(res.ds[0].Creater))
                            that.formData.UserName = res.ds[0].Creater
                            if (APP.getUserInfo().UserName == res.ds[0].Creater) {
                                res.ds.map((item) => {
                                    if (item.Approve == 2) {
                                        that.approveFalg = true
                                    }
                                })
                                console.log('approveFalg', JSON.stringify(that.approveFalg))
                            }


                            var data = [];
                            allCurrentApprovalIDs = [];
                            var allCurrentApprovalIDs2 = [];
                            for (var i in res.ds) {

                                res.ds[i].CurrentApprovalIDs = res.ds[i].CurrentApprovalIDs ? res.ds[i].CurrentApprovalIDs.replace(/^,+/, "").replace(/,+$/, "").split(',') : '';
                                res.ds[i].showAll = false

                                allCurrentApprovalIDs = allCurrentApprovalIDs.concat(res.ds[i].CurrentApprovalIDs);
                                if (res.ds[i].FlowType != 1) {
                                    allCurrentApprovalIDs2 = allCurrentApprovalIDs2.concat(res.ds[i].CurrentApprovalIDs);
                                }
                                for (var c in res.ds[i].CurrentApprovalIDs) {
                                    var row = that.filterPersonList('UserID', res.ds[i].CurrentApprovalIDs[c])
                                    if (row) {
                                        res.ds[i].CurrentApprovalIDs[c] = row.UserName;
                                    }
                                }

                                if (data.indexOf(res.ds[i].AuditID) == -1) {
                                    data.push(res.ds[i].AuditID);
                                }
                            }

                            var approvalList = [];
                            for (var n in data) {
                                var approvalNodeList = [];
                                var level = 0;
                                var finLevel = 0;
                                for (var i in res.ds) {
                                    if (data[n] == res.ds[i].AuditID) {

                                        if (res.ds[i].Approve == 0 && !level) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 1 && i == res.ds.length - 1) {
                                            level = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && !finLevel) {
                                            finLevel = res.ds[i].ApprovalSort;
                                        }

                                        if (res.ds[i].Approve == 2 && n == data.length - 1) {
                                            that.finalResult = true;
                                        }

                                        var x = 0;
                                        for (var j in approvalNodeList) {
                                            if (approvalNodeList[j].index == res.ds[i].ApprovalSort) {
                                                x = 1;
                                                approvalNodeList[j].node.push(res.ds[i]);
                                            }
                                        }
                                        if (!x) {
                                            approvalNodeList.push({
                                                index: res.ds[i].ApprovalSort,
                                                type: res.ds[i].FlowType,
                                                department: res.ds[i].ApprovalName,
                                                node: [res.ds[i]]
                                            })
                                        }
                                    }
                                }
                                // console.log('length', JSON.stringify(res.ds[res.ds.length - 1]))
                                if (res.ds[res.ds.length - 1].Approve == 1) {
                                    that.finalBtn = true
                                }
                                if (res.ds[0].CurrentApprovalIDs.includes(APP.getUserInfo().UserName)) { //限制扣款原因只有一级人员才能填写
                                    that.FRemarksEdit = false
                                }
                                approvalList.push({
                                    level: finLevel ? (finLevel - 1) : (level - 1),
                                    approvalNodeList: approvalNodeList
                                })
                            }

                            var p1 = 0;
                            var y = 0;
                            if (that.finalResult == 1) {
                                for (var i in res.ds) {
                                    if (res.ds[i].Approver && res.ds[i].FlowType != 1) {
                                        p1++;
                                        if (res.ds[i].Approver == that.userData.UserName) {
                                            y = 1;

                                        }
                                    }

                                }

                                // console.log('Ck_DeductPSReviewID', JSON.stringify(that.formData.Ck_DeductPSReviewID))
                            }

                            that.approvalList = approvalList;
                            console.log('approvalList', JSON.stringify(that.approvalList))
                        })
                    })
                },

                checkIsShowButton: function () {
                    var that = this;
                    var obj = {
                        P_TableName: 'Pr_DeductMoney',
                        P_PKValue: that.formData.DeductMoneyID
                    }
                    console.log('Btnobj', JSON.stringify(obj))
                    APP.ajax('WhetherItCanBeApproved', obj, function (res) {
                        console.log('Btnres', JSON.stringify(res))
                        that.btnShow = res.ds[0].ISSP;
                    })
                },

                approveSave() {
                    var that = this
                    obj = {
                        Approve: that.approveFlag,
                        TableName: 'Pr_DeductMoney',
                        KeyID: that.formData.DeductMoneyID,
                        ApprovalContent: that.approveData.approveData,
                        ApprovalID: that.approvalID,
                        ApprovalSort: that.approvalList[that.approvalList.length - 1].level + 1,
                        Imgs: '',
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('Ck_ApprovalForm', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].STATUS == 0) {
                            var obj1 = {
                                BadReviewID: that.formData.DeductMoneyID,
                                UserID: APP.getUserInfo().UserID,
                                status: that.approveFlag == 1 ? 0 : 1,
                                ReviewType: 5,
                                SourceTable: 'Pr_DeductMoney'
                            }
                            console.log('obj1', JSON.stringify(obj1))
                            APP.ajax('selectQJPSSPZTByUserID', obj1, function (res) {
                                console.log('res', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    api.toast({
                                        msg: res.ds[0].msg
                                    })
                                    that.addSP_Message(that.approveFlag)

                                    api.sendEvent({
                                        name: 'refresh'
                                    })
                                    setTimeout(() => {
                                        api.closeWin()
                                    }, 1500)
                                } else {
                                    api.toast({
                                        msg: res.ds[0].msg
                                    })
                                }
                            })
                        } else {
                            vm.$toast(res.ds[0].msg)
                        }
                    })
                },

                saveRow() {
                    that = this
                    var shouldProceed = true
                    that.approveDisabled = true;
                    if (that.formData.SupplierName == '') {
                        api.toast({
                            msg: '请输入责任单位'
                        })
                        that.approveDisabled = false;
                        return false
                    }

                    that.tableData.forEach(item => {
                        if (item.ProductName == '') {
                            api.toast({
                                msg: '请填写品名！'
                            })
                            shouldProceed = false;  // 如果发现空值，设置标志为false  
                            that.approveDisabled = false;
                        }
                    })
                    if (shouldProceed) {
                        var obj
                        if (api.pageParam.historyData) {
                            obj = {
                                ProductName: that.tableData.map(item => item.ProductName).join('~'),
                                TotalQuantity: that.tableData.map(item => item.TotalQuantity).join('~'),
                                DeductMoneyDeID: that.tableData.map(item => item.DeductMoneyDeID).join('~'),
                                TotalMoney: that.tableData.map(item => item.TotalMoney).join('~'),
                                CPTH: that.tableData.map(item => item.CPTH).join('~'),
                                FRemarks: that.tableData.map(item => item.FRemarks).join('~'),
                                LossCharge: that.tableData.map(item => item.LossCharge).join('~'),
                                TransportationCharge: that.tableData.map(item => item.TransportationCharge).join('~'),
                                PenaltyFee: that.tableData.map(item => item.PenaltyFee).join('~'),
                                DisqualificationRatio: that.tableData.map(item => item.DisqualificationRatio).join('~'),
                                CustomerFee: that.tableData.map(item => item.CustomerFee).join('~'),
                                OtherFee: that.tableData.map(item => item.OtherFee).join('~'),
                                FilePath: that.imgList.map(item => item.url).join(','),
                                FilePath1: that.videoList.map(item => item.url).join('~'),
                                FilePath2: that.videoImgList.map(item => item.url).join('~'),
                                DeductMoneyID: that.formData.DeductMoneyID,
                                ZBTotalMoney: that.formData.TotalMoney

                            }
                            console.log('obj', JSON.stringify(obj))
                            APP.ajax('APP_Update_GYSZLKK', obj, function (res) {
                                //console.log('res', JSON.stringify(res))
                                that.approveDisabled = false;
                                if (res.ds[0].status == 200) {
                                    api.toast({
                                        msg: '提交成功！'
                                    })
                                    that.handlerApprove()
                                } else {
                                    vm.$toast('修改失败，请重试！');
                                }
                            })
                        } else {
                            obj = {
                                CPTH: that.tableData.map(item => item.CPTH).join('@'),
                                TotalQuantity: that.tableData.map(item => item.TotalQuantity).join('~'),
                                FRemarks: that.tableData.map(item => item.FRemarks).join('~'),
                                ProductName: that.tableData.map(item => item.ProductName).join('~'),
                                TotalMoney: that.tableData.map(item => item.TotalMoney).join('~'),
                                LossCharge: that.tableData.map(item => item.LossCharge).join('~'),
                                DisqualificationRatio: that.tableData.map(item => item.DisqualificationRatio).join('~'),
                                PenaltyFee: that.tableData.map(item => item.PenaltyFee).join('~'),
                                TransportationCharge: that.tableData.map(item => item.TransportationCharge).join('~'),
                                CustomerFee: that.tableData.map(item => item.CustomerFee).join('~'),
                                OtherFee: that.tableData.map(item => item.OtherFee).join('~'),
                                FilePath: that.imgList.map(item => item.url).join(','),
                                FilePath1: that.videoList.map(item => item.url).join('~'),
                                FilePath2: that.videoImgList.map(item => item.url).join('~'),
                                FRemarks1: that.formData.FRemarks,
                                OrderNumber: that.formData.OrderNumber,
                                SupplyName: that.formData.SupplierName,
                                ZBTotalMoney: that.formData.TotalMoney
                            }
                            console.log('obj', JSON.stringify(obj))
                            console.log('name', APP.getUserInfo().UserName)
                            that.approveDisabled = false;
                            window.localStorage.setItem('name', APP.getUserInfo().UserName);
                            APP.ajax('APP_ADD_GYSZLKK', obj, function (res) {
                                console.log('res', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    that.formData.DeductMoneyID = res.ds[0].DeductMoneyID
                                    that.formData.BillNO = res.ds[0].BillNO3
                                    that.handlerApprove()

                                } else {
                                    vm.$toast('新增失败，请重试！');
                                }
                            })

                        }
                    }
                },

                handlerApprove() {
                    var that = this
                    var obj1 = {
                        IsReworkDepart: -1,
                        NgCause: that.formData.Comment,
                        FRemarks: that.formData.FRemarks,
                        UserID: APP.getUserInfo().UserID,
                        BadReviewID: that.formData.DeductMoneyID,
                        P_Timeout: 0,
                        ReviewType: 5
                    }
                    console.log('obj1', JSON.stringify(obj1))
                    APP.ajax('addBHGPSReviewApprove', obj1, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].Ck_ReviewID) {
                            that.formData.Ck_DeductPSReviewID = res.ds[0].Ck_ReviewID
                            var obj2 = {
                                TableName: 'Pr_DeductMoney',
                                APFlowID: 7,
                                approveType: 0,
                                Ck_ReviewID: that.formData.Ck_DeductPSReviewID,
                                ApprovalID: that.formData.DeductMoneyID,
                                ReviewType: 5
                            }
                            console.log('obj2', JSON.stringify(obj2))
                            APP.ajax('BhgpsbgApprove', obj2, function (res) {
                                console.log('BhgpsbgApprove', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    vm.$toast('发起审批成功!');
                                } else {
                                    api.toast({
                                        msg: res.ds[0].msg
                                    })
                                }
                            })
                            api.sendEvent({
                                name: 'refresh'
                            })
                            setTimeout(() => {
                                api.closeWin()
                            }, 1500)
                        } else {
                            api.toast({
                                msg: '发起审批失败，请重试'
                            })
                        }
                    })

                    api.sendEvent({
                        name: 'refresh'
                    })
                },

                submit(flag) {
                    var that = this
                    that.approveFlag = flag
                    if (flag != 0) {  //同意/拒绝
                        that.approveShow = true
                    } else {  //重新发起审批
                        var obj1 = {
                            BadReviewID: that.formData.DeductMoneyID,
                            NgCause: that.formData.Comment,
                            UserID: APP.getUserInfo().UserID,
                            IsReworkDepart: 1,
                            ClassID: that.formData.ClassID,
                            Ck_BHGPSReviewID: that.formData.Ck_DeductPSReviewID,
                            P_Timeout: 0,
                            ReviewType: 5
                        }
                        console.log('obj1', JSON.stringify(obj1))
                        APP.ajax('updateBHGPSApproveReview', obj1, function (res) {
                            console.log('obj1res', JSON.stringify(res))
                            if (res.ds && res.ds[0].status == 500) {
                                vm.$toast(res.ds[0].msg)
                            } else {
                                var obj = {
                                    ProductName: that.tableData.map(item => item.ProductName).join('~'),
                                    TotalQuantity: that.tableData.map(item => item.TotalQuantity).join('~'),
                                    DeductMoneyDeID: that.tableData.map(item => item.DeductMoneyDeID).join('~'),
                                    TotalMoney: that.tableData.map(item => item.TotalMoney).join('~'),
                                    CPTH: that.tableData.map(item => item.CPTH).join('~'),
                                    FRemarks: that.tableData.map(item => item.FRemarks).join('~'),
                                    LossCharge: that.tableData.map(item => item.LossCharge).join('~'),
                                    TransportationCharge: that.tableData.map(item => item.TransportationCharge).join('~'),
                                    PenaltyFee: that.tableData.map(item => item.PenaltyFee).join('~'),
                                    DisqualificationRatio: that.tableData.map(item => item.DisqualificationRatio).join('~'),
                                    CustomerFee: that.tableData.map(item => item.CustomerFee).join('~'),
                                    OtherFee: that.tableData.map(item => item.OtherFee).join('~'),
                                }
                                console.log('obj', JSON.stringify(obj))
                                APP.ajax('APP_Update_GYSZLKK', obj, function (res) {
                                    console.log('res', JSON.stringify(res))
                                    if (res.ds[0].status == 200) {
                                        that.addSP_Message(that.approveFlag)
                                        api.toast({
                                            msg: '重新发起审批成功！'
                                        })
                                    }
                                })
                            }
                        })
                    }
                },

                openBaseScreen: function (str, index) {
                    var that = this;
                    that.currentRowIndex = index
                    var obj;
                    if (str == '品名') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: 'ProductName',
                            serverSearch: true,
                            searchBy: ['ProductName'],
                            isPaging: true,
                            type: str,
                            cmd: 'APP_DG_CPXL',
                            param: {
                                pageIndex: 1,
                                pageSize: 20
                            }
                        }
                    }
                    api.openWin({
                        name: 'baseScreen',
                        url: '../tool/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: obj
                    })
                },

                onClickLeft() {
                    api.closeWin();
                },

                //摄像头扫描事件
                openScan() {
                    var resultList = api.hasPermission({
                        list: ['camera']
                    });
                    if (resultList[0].granted) {
                        // 已授权，可以继续下一步操作
                        FNScanner.open({
                            autorotation: true
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.content) {
                                    api.sendEvent({
                                        name: 'scanHandler',
                                        extra: {
                                            scanData: ret.content
                                        }
                                    })
                                }
                            } else {
                                vm.$toast('扫描失败');
                            }
                        });
                    } else {
                        api.confirm({
                            msg: '应用需要您的授权才能访问相机',
                            buttons: ['取消', '去设置']
                        }, function (ret) {
                            if (ret.buttonIndex == 2) {
                                api.requestPermission({
                                    list: ['camera'],
                                }, function (res) {
                                    if (res.list[0].granted) {
                                        // 已授权，可以继续下一步操作
                                        FNScanner.open({
                                            autorotation: true
                                        }, function (ret, err) {
                                            if (ret) {
                                                if (ret.content) {
                                                    api.sendEvent({
                                                        name: 'scanHandler',
                                                        extra: {
                                                            scanData: ret.content
                                                        }
                                                    })
                                                }
                                            } else {
                                                vm.$toast('扫描失败');
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }


                    // var hwScanner = api.require('hwScanner');
                    // hwScanner.defaultScanner({
                    //     formatType: 'ALL'
                    // }, function (ret) {
                    //     if (ret.status) {
                    //         api.sendEvent({
                    //             name: 'scanHandler',
                    //             extra: {
                    //                 scanData: ret.result
                    //             }
                    //         })
                    //     }
                    //     else {
                    //         vm.$toast('扫描失败');
                    //     }
                    // });
                },

                //打开打印
                openPrint() {
                    if (vm.printConfig) {
                        var script = vm.printConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
            }
        })
    };
</script>

</html>